<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8">
    <title>新建用车申请</title>
    <meta name="renderer" content="webkit">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
    <meta name="apple-mobile-web-app-status-bar-style" content="black">
    <meta name="apple-mobile-web-app-capable" content="yes">
    <meta name="format-detection" content="telephone=no">
    <link rel="stylesheet" href="<%=request.getContextPath()%>/static/layui/layui/css/layui.css" media="all" />
    <link rel="stylesheet" href="<%=request.getContextPath()%>/static/css/public.css" media="all" />
</head>
<body class="childrenBody">
<form class="layui-form" method="post" id="applyForm">
    <div class="layui-form-item">
        <label class="layui-form-label">用车人</label>
        <div class="layui-input-block">
            <input type="text" id="caruser" name="caruser" required  lay-verify="required" placeholder="请输入用车人姓名" autocomplete="off" class="layui-input">
        </div>
    </div>

    <div class="layui-form-item">
        <label class="layui-form-label">联系方式</label>
        <div class="layui-input-block">
            <input type="text" id="applytel" name="applytel" required  lay-verify="required" placeholder="请输入联系方式" autocomplete="off" class="layui-input">
        </div>
    </div>

    <div class="layui-form-item">
        <label class="layui-form-label">用车时间:</label>
        <div class="layui-input-block">
            <input type="text" name="usestarttime" required  lay-verify="required" placeholder="请输入用车时间" class="layui-input usetime">
        </div>
    </div>

    <div class="layui-form-item">
        <label class="layui-form-label">预计归还:</label>
        <div class="layui-input-block">
            <input type="text" id="useendtime" name="useendtime" required  lay-verify="required" placeholder="请输入预计归还时间" autocomplete="off" class="layui-input usetime">
        </div>
    </div>

    <div class="layui-form-item">
        <label class="layui-form-label">出发地点:</label>
        <div class="layui-input-block">
            <input type="text" id="go" name="go" required  lay-verify="required" placeholder="请输入出发地点" autocomplete="off" class="layui-input">
            <br/>
            <a class="layui-btn layui-btn-normal" id="Map">打开地图</a>
        </div>
    </div>

    <div class="layui-form-item">
        <label class="layui-form-label">目的地:</label>
        <div class="layui-input-block">
            <input type="text" id="back" name="back" required  lay-verify="required" placeholder="请输入目的地" autocomplete="off" class="layui-input">
            <br/>
            <a class="layui-btn layui-btn-normal" lay-event="openMap">打开地图</a>
        </div>
    </div>

    <div class="layui-form-item">
        <label class="layui-form-label">事由及说明:</label>
        <div class="layui-input-block">
            <textarea name="remark" id="remark" cols="76" rows="12">
                事由：

                同车人：

                对车辆司机的要求：无
            </textarea>
        </div>
    </div>

    <div class="layui-form-item">
        <div class="layui-input-block">
            <button class="layui-btn" lay-submit lay-filter="applyAdd" id="addBtn">立即提交</button>
            <button type="reset" class="layui-btn layui-btn-primary">重置</button>
        </div>
    </div>

</form>
<script type="text/javascript" src="<%=request.getContextPath()%>/static/layui/layui/layui.js"></script>
<script type="text/javascript">
    layui.use(['form','layer','laydate','table','laytpl','upload'],function(){
        var form = layui.form,
            layer = parent.layer === undefined ? layui.layer : top.layer,
            $ = layui.jquery,
            laydate = layui.laydate,
            laytpl = layui.laytpl,
            table = layui.table,
            upload=layui.upload;

        //绑定时间插件到文本框中
        $(".usetime").each(function () {
            laydate.render({
                elem:this,
                theme: 'grid',
                type: 'datetime'
            });
        });


        //提交表单
        form.on("submit(applyAdd)",function(data) {
            // var formData = new FormData($("#applyForm")[0]);
            $.ajax({
                url:"/car/doApplyAdd",
                type: "post",
                data:$("#applyForm").serialize(),
                success:function (res) {
                    if(res.code == 1001){
                        layui.layer.msg(res.msg);
                    }else{
                        layui.layer.msg(res.msg);
                    }
                }
            });
            //点击提交后关闭悬浮窗
            setTimeout(function () {
                window.parent.location.reload();
            },1500);
            return false;
        });

    })
</script>
</body>
</html>